// routes/todoRoutes.js
const express = require('express');
const todoController = require('../controllers/todoController');

const router = express.Router();


/**
 * @swagger
 * /api/todos:
 *   post:
 *     tags:
 *       - 待办事项
 *     summary: 创建一个新的待办事项
 *     requestBody:
 *       required: true
 *       content:
 *         application/json:
 *           schema:
 *             type: object
 *             properties:
 *               title:
 *                 type: string
 *                 required: true
 *               completed:
 *                 type: boolean
 *               description:
 *                 type: string
 *     responses:
 *       201:
 *         description: 待办事项创建成功
 *         content:
 *           application/json:
 *             schema:
 *               type: object
 *               properties:
 *                 id:
 *                   type: string
 *                 title:
 *                   type: string
 *                 completed:
 *                   type: boolean
 *                 createdAt:
 *                   type: string
 *                 updatedAt:
 *                   type: string
 *             example:
 *               id: "645d8b4c2c1a9f8a7c7d7e8e"
 *               title: "购买牛奶"
 *               completed: false
 *               createdAt: "2023-11-01T08:00:00.000Z"
 *               updatedAt: "2023-11-01T08:00:00.000Z"
 *       400:
 *         description: 缺少必填字段
 *         content:
 *           application/json:
 *             schema:
 *               type: object
 *               properties:
 *                 error:
 *                   type: string
 *             example:
 *               error: "标题是必需的"
 *       500:
 *         description: 服务器错误
 *         content:
 *           application/json:
 *             schema:
 *               type: object
 *               properties:
 *                 error:
 *                   type: string
 *             example:
 *               error: "创建待办事项失败"
 */
// 获取所有待办事项
router.get('/', todoController.getAllTodos);

// 创建新的待办事项
router.post('/', todoController.createTodo);

// 删除待办事项
router.delete('/:id', todoController.deleteTodo);

// 更新待办事项状态
router.patch('/:id', todoController.updateTodoStatus);

// 获取学生信息
router.get('/student-info', todoController.getStudentInfo);

module.exports = router;